/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mac;

import java.io.*;
import java.security.*;

public class CalculaMac {

    public static void main(String[] args) throws Exception {
//        if (args.length != 1) {
//            System.err.println(
//                    "Indique el fichero al que calcular su MAC");
//            return;
//        }
        System.out.print("Indique passphrase:");
        BufferedReader teclado = new BufferedReader(
                new InputStreamReader(System.in));
        String passphrase = "123456";
        FileInputStream fis =
                new FileInputStream("mydata.txt");
        FileOutputStream fos =
                new FileOutputStream("mydata.txt" + ".mac");
        MessageDigest md = MessageDigest.getInstance("SHA");
        DigestInputStream dis =
                new DigestInputStream(fis, md);
        md.update(passphrase.getBytes());
        while (dis.read() != -1);
        fos.write(md.digest());
        fis.close();
        fos.close();
    }
}
